package it.abc.sicsic.view.backing.skipper;

import it.abc.sicsic.JavaServiceFacade;
import it.abc.sicsic.model.skipper.Skipper;
import it.abc.sicsic.view.backing.NauticaTemplate;
import it.abc.sicsic.view.util.ViewUtil;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.adf.view.rich.component.rich.input.RichInputText;

//import org.apache.log4j.Logger;

@ManagedBean(name = "backing_gestioneSkipper")
@SessionScoped

public class GestioneSkipper {

    private RichInputText itNome;
    private RichInputText itNatoIl;
    private RichInputText itNatoA;
    private RichInputText itResidenza;
    private RichInputText itPatenteNautica;
    private RichInputText itRilasciataDa;
    private RichTable tableSkipper;
  //  private static Logger logger = Logger.getLogger(GestioneSkipper.class);
    
    public GestioneSkipper(){
   //     logger.info("GestioneSkipper start");
   //     logger.info("fromPage=" + ViewUtil.getRequestFromPage());       
    }
    
    public void setItNome(RichInputText itNome) {
        this.itNome = itNome;
    }

    public RichInputText getItNome() {
        return itNome;
    }

    public void setItNatoIl(RichInputText itNatoIl) {
        this.itNatoIl = itNatoIl;
    }

    public RichInputText getItNatoIl() {
        return itNatoIl;
    }

    public void setItNatoA(RichInputText itNatoA) {
        this.itNatoA = itNatoA;
    }

    public RichInputText getItNatoA() {
        return itNatoA;
    }

    public void setItResidenza(RichInputText itResidenza) {
        this.itResidenza = itResidenza;
    }

    public RichInputText getItResidenza() {
        return itResidenza;
    }

    public void setItPatenteNautica(RichInputText itPatenteNautica) {
        this.itPatenteNautica = itPatenteNautica;
    }

    public RichInputText getItPatenteNautica() {
        return itPatenteNautica;
    }

    public void setItRilasciataDa(RichInputText itRilasciataDa) {
        this.itRilasciataDa = itRilasciataDa;
    }

    public RichInputText getItRilasciataDa() {
        return itRilasciataDa;
    }
    
    private String getNome(){
        return ViewUtil.getStringValue(getItNome());
    }
    private String getNatoIl(){
        return ViewUtil.getStringValue(getItNatoIl());
    }
    private String getNatoA(){
        return ViewUtil.getStringValue(getItNatoA());   
    }
    private String getResidenza(){
        return ViewUtil.getStringValue(getItResidenza());
    }
    private String getPatenteNautica(){
        return ViewUtil.getStringValue(getItPatenteNautica());
    }
    private String getRilasciataDa(){
        return ViewUtil.getStringValue(getItRilasciataDa());
    }

    public void cerca(ActionEvent actionEvent) {
        JavaServiceFacade serviceFacade = new JavaServiceFacade();
        List<Skipper> list = null;
        list = serviceFacade.getSkipper(getNome(), getResidenza());
        tableSkipper.setValue(list);
    }

    public void setTableSkipper(RichTable tableSkipper) {
        this.tableSkipper = tableSkipper;
    }

    public RichTable getTableSkipper() {
        return tableSkipper;
    }

}
